//
//  YJCategoryProductListCell.m
//  SnackCourier
//
//  Created by qianfeng01 on 15/7/23.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "YJCategoryProductListCell.h"

@implementation YJCategoryProductListCell

- (void)awakeFromNib {
    CGFloat w=(self.frame.size.width-40)/3.0;
    CGFloat h=(self.frame.size.height-10)/2.0;
    for (int i=0; i<6; i++) {
      _sView =[[[NSBundle mainBundle] loadNibNamed:@"YJcategoryBelowView" owner:self options:nil] lastObject];
        if (i<3) {
            _sView.frame =CGRectMake(10+(i%3)*(10+w),-0.01, w, h);
        }else{
            _sView.frame =CGRectMake(10+(i%3)*(10+w),(i/3)*h+10, w, h);
        }
        _sView.tag =101+i;
        [self.contentView addSubview:_sView];
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)showDataWithArray:(NSMutableArray *)array myblock:(BlowBlock)myblock{
    self.array=array;
    self.myblock =myblock;
    for (int i=0; i<array.count; i++) {
        YJcategoryBelowView *view =(YJcategoryBelowView *)[self.contentView viewWithTag:101+i];
        [view showDataWithModel:array[i]];
        [view addTarget:self action:@selector(Click:)];
    }
}

-(void)Click:(YJcategoryBelowView *)view{
    if (self.myblock) {
        YJcategoryBelowModel *mode =self.array[view.tag-101];
        self.myblock(mode.id);
    }
    
}

@end
